<template>
	<view>
		<template v-if="page_loading">
			<Loading />
		</template>
		<template v-else>
			<Empty v-if="productList.length===0"></Empty>
			
		</template>
		<product-list :productList="productList"></product-list>
	</view>
</template>

<script>
	import Loading from '../../components/loading/loading.vue'
	import Empty from '../../components/empty/empty.vue'
	export default {
		components: {
			Loading,
			Empty
		},
		data() {
			return {
				loadId: 0,
				productList: [],
				page: 1,

				page_loading: true,
			};
		},
		onLoad(data) {
			this.loadId = data.loadId;
			uni.setNavigationBarTitle({
				title: data.title
			})
		},
		onReady() {
			this.loadProduct();
		},
		onReachBottom() {
			this.loadProduct();
		},
		methods: {
			loadProduct() {
				let params = {
					cate_id: this.loadId,
					page: this.page,
					limit: 20
				};
				this.$api('Product/lists', params).then(data => {

					if (data.status == 1) {
						// this.productLis = data.data.product
						this.productList.push(...data.data.product);
						this.page += 1

						if (this.page_loading) this.page_loading = false

					} else {
						this.$showToast(data.msg);
					}
				})
			}
		}
	}
</script>

<style lang="scss">

</style>